import type { AppointformResultParams } from '@/types/appointform'
import { http, ajhttp } from '@/utils/http'

/**
 * 修改/新增预约表单模板
 * @param data 请求参数
 */
type AppointformSaveParams = {
  hardwareCode: string
  formSchema: string
}
export const appointformSave = (data: AppointformSaveParams) => {
  return ajhttp<AppointformResultParams>({
    method: 'POST',
    url: `/system/appointform/save`,
    data,
  })
}

/**
 * 提交预约表单
*/
type orderItems = {
  formKey: string
  formValue: string
}
type AppointformSubmitParams = {
  hardwareCode: string
  wxmpOpenId: string
  items: orderItems
}
export const appointformSubmit = (data: AppointformSubmitParams) => {
  return http<AppointformResultParams>({
    method: 'POST',
    url: `/system/appointform/submit`,
    data,
  })
}

/**
 * 审核预约表单
*/
type AppointformAuditParams = {
  recordIdList: string[]
  pass: boolean
  failReason: string
}
export const onAppointformSubmit = (data: AppointformAuditParams) => {
  return ajhttp<AppointformResultParams>({
    method: 'POST',
    url: `/system/appointform/audit`,
    data,
  })
}

/**
 * 审核预约表单
*/
export const getRecords = (data: { id?: number, code: string, carNo: string, page: number, limit: number }) => {
  return ajhttp<AppointformResultParams>({
    method: 'GET',
    url: `/system/appointform/records`,
    data,
  })
}
